import { Entity, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn ,Column} from "typeorm";
import { UserAccount } from 'src/user_account/entities/user_account.entity'
import { Conversation } from "./conversation.entity";
@Entity({name:'sender_message_receiver'})
export class Message {
    @PrimaryGeneratedColumn()
    id: number;

    @ManyToOne(() => UserAccount, sender => sender.messages)
    sender: UserAccount;

    @ManyToOne(() => UserAccount, receiver => receiver.received_messages)
    receiver: UserAccount;

    @ManyToOne(() => Conversation, conversation => conversation.messages)
    conversation: Conversation;

    @Column()
    content: string;

    @Column({ default: false })
    read: boolean;

    @Column({ default: () => 'CURRENT_TIMESTAMP' })
    createdTime: Date;

}
